package com.example.Sao.MyFragment;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.example.Sao.R;
import com.wang.avi.AVLoadingIndicatorView;

/**
 * @ProjectName: scan
 * @Package: com.example.MyApplication.MyFragment
 * @ClassName: RoomInforFragment
 * @Description: java类作用描述
 * @Author: 作者名
 * @CreateDate: 2020/3/3 17:13
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/3/3 17:13
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class RoomInforFragment extends DialogFragment implements View.OnClickListener{
    private AVLoadingIndicatorView Aview;
    private DataBcakListener dataBcakListener;
    private Context mContext;
    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        return super.onCreateDialog(savedInstanceState);
    }

    public void setDataBcakListener(DataBcakListener dataBcakListener) {
        this.dataBcakListener = dataBcakListener;
    }

    public void setmContext(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_back:
                break;
            case R.id.iv_sure:
                break;
            default:
                break;
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Window window = this.getDialog().getWindow();
        //去掉dialog默认的padding
        DisplayMetrics dm = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
        window.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (int) (dm.widthPixels * 0.75);
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //设置dialog的位置在中间
        lp.gravity = Gravity.CENTER;
        //设置dialog的动画
        lp.windowAnimations = R.style.dialogAnim;
        window.setAttributes(lp);
        window.setBackgroundDrawable(new ColorDrawable());
        View view = inflater.inflate(R.layout.fragment_room_info,container,false);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        Aview  = view.findViewById(R.id.avi);
        super.onViewCreated(view, savedInstanceState);
    }

    @Override
    public void onStart() {
        super.onStart();
        Aview.show();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public interface DataBcakListener{
        public void dataBcakListener(String data);
    }
}